
let kouul=document.querySelector('.kou ul')
let xhr =new XMLHttpRequest()
xhr.open('get','http://chst.vip:1234/api/getmoneyctrl',true)
xhr.onload=function(){
    if(xhr.status===200){
        let res =JSON.parse(xhr.responseText)
        let an=res .result
        let lis=''
        console.log(an);
        an.forEach(item => {
            lis+=`
            <li productid=${item.productId}>
                <img src="${item.productImgSm.match(/imgurl=(\S*)/)[1]}">
                <div class="inx">
                    <p class="p1">${item.productName}</p>
                    <p class="p2">${item.productPinkage}</p>
                    <span class="span1">${item.productFrom}|${item.productTime}</span>
                    <i class="iconfont icon-xinxi"></i> 
                    <span class="span2">${item.productComCount}</span> 
                </div>
            </li> 
            `  
        });
        kouul.innerHTML=lis
    }
}
xhr.send(null)


kouul.onclick=function(e){
    var e = e || window.event;
    var target = e.target || e.srcElement;
    if(target.nodeName==='DIV' || target.nodeName==='IMG'){
        console.log(target.parentNode.getAttribute('productid'));
        localStorage.setItem('productid',target.parentNode.getAttribute('productid'))
        location.href = 'http://127.0.0.1:5500/js/day18/html/details.html';
        

    }else{
        localStorage.setItem('productid',target.parentNode.parentNode.getAttribute('productid'))
        console.log(target.parentNode.parentNode.getAttribute('productid'));
        location.href = 'http://127.0.0.1:5500/js/day18/html/details.html';
       
    }
    
}

// 更多下拉栏
let dian=document.querySelector('.one .dian')
let one=document.querySelector('.one')
let dis=document.querySelector('.dis')
$('.one .dis').slideUp(0)
$('.one .dian').click(function(){
    console.log( $(this).nextAll());
    $(this).parent().next('.dis').slideToggle().parent().next('.dis').slideUp()

})


   



